#!/usr/bin/python

from tkinter import*
import os
import shutil

def getFileExt(fileName):
    token = fileName.split(".");
    return token[len(token)-1];

def runConverter(filePath):
    print(filePath);
    pipe = os.popen("dir \"" + filePath + "\"");
    print(pipe.read());
    return;

def onBtnClick():
    path = entry.get();
    dirList = os.listdir(path);

    for name in dirList:
        if os.path.isdir(name):
            continue;

        fileExtName = getFileExt(name);
        if (fileExtName != "mod" and fileExtName != "MOD"):
            continue;

        runConverter(os.path.join(path, name));

    messagebox.showinfo("알림", "끝났습니다.");
    
    return;

app = Tk();
app.title("컨버터");
app.geometry('400x90+200+100');

label = Label(app, text = "폴더 경로");
label.pack();

entry = Entry(app, text="path", width = 50);
entry.pack(pady = 5);

button = Button(app, text = "변환", width = 10, command = onBtnClick);
button.pack(padx = 5);

app.mainloop();
